 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
	"http://www.w3.org/TR/html4/loose.dtd">

<?php
ini_set('display_errors', 'on');
session_start();
?>

<html>
	<head>
		<link rel="stylesheet" type="text/css" href="styles/layout.css">
	</head>
	
	<body>
			<?php
				//Connect to the database.
				$con = mysqli_connect ("localhost", 'root', 'ilovesloths13', '4350');

				if (mysqli_connect_errno()) {
				  echo "Failed to connect to MySQL: " . mysqli_connect_error();
				  require("footer.php");
				  die;
				}
			?>

		 <div class="wrapper">


		 	<!-- HEADING -->
		 	<div class='heading'>
		 		<a href="home.php">Super Awesome Happyland of Car Parts and Joy</a>
		 	</div>

			<!-- NAVIGATION -->
			<?php if (isset($_SESSION["man_id"])) { ?>
				<div class ='nav'>
					<ul>
						<li><a href='addEmployee.php'>Add Employee</a></li>
						<li><a href='editEmployee.php'>Edit Employee</a></li>
						<li><a href='payroll.php'>Payroll</a></li>
						<li><a href='addNewItem.php'>New Item</a></li>
						<li><a href='modifyStock.php'>Modify Stock</a></li>
						<li><a href='salesReport.php'>Sales Report</a></li>
						<li><a href='customerOrderHistory.php'>Order History</a></li>
					</ul>
			<?php } else if(isset($_SESSION["emp_id"])) { ?>
				<div class='nav'>
					<ul>
						<li><a href='employeeHome.php'>Home</a></li>
					</ul>
			<?php } else { ?>
				<div class='nav'>
					<ul>
						<li><a href='browse-parts.php'>Browse Parts</a></li>
						<li><a href='search-parts.php'>Search Parts</a></li>
						<li><a href='orderHistory.php'>Order History</a></li>
						<li><a href='cart.php'>My Cart</a></li>
						<li><a href='userSettings.php'>My Settings</a></li>
					</ul>
				<?php } ?>

				<!-- LOGIN VERIFICATION -->
				<span class='login_status'>
					<?php 

						$userPages = array();
						$userPages['home'] = "/csce4350-project/home.php";
						$userPages['login'] = "/csce4350-project/login.php";
						$userPages['employee-login'] = "/csce4350-project/employeeLogin.php";
						$userPages['new-user'] = "/csce4350-project/new-user.php";
						$userPages['create-account'] = "/csce4350-project/create-account.php";
						
						$managerPages = array();
						$managerPages['add-employee'] = "/csce4350-project/addEmployee.php";
						$managerPages['edit-employee'] = "/csce4350-project/editEmployee.php";
						$managerPages['payroll'] = "/csce4350-project/payroll.php";
						$managerPages['add-item'] = "/csce4350-project/addNewItem.php";
						$managerPages['modify-stock'] = "/csce4350-project/modifyStock.php";
						$managerPages['sales-report'] = "/csce4350-project/salesReport.php";
						$managerPages['cust-order-history'] = "/csce4350-project/customerOrderHistory.php";

						if (!isset($_SESSION['email']) && !isset($_SESSION['emp_id']) && !in_array($_SERVER["REQUEST_URI"], $userPages)) { // You are not logged in and are on a user page you are not allowed to view
							echo "<a href='login.php'> Login </a> | <a href='new-user.php'> Register </a>";
							echo "</span></div><div class='main'>";
							echo "You must be logged in to view this page.";
							require('footer.php');
							die();
						} else if (!isset($_SESSION['email']) && !isset($_SESSION['emp_id']) && in_array($_SERVER["REQUEST_URI"], $userPages)) { // You are not logged in and are on the home page
							echo "<a href='login.php'> Login </a> | <a href='new-user.php'> Register </a>";
						} else if (!isset($_SESSION['man_id']) && !isset($_SESSION["email"]) && in_array($_SERVER["REQUEST_URI"], $managerPages)) { //You are not logged in and are on a manager page
							echo "<a href='login.php'> Login </a> | <a href='new-user.php'> Register </a>";
							echo "</span></div><div class='main'>";
							echo "You must be logged in as a manager to view this page.";
							require('footer.php');
							die();
						} else if (!isset($_SESSION['man_id']) && isset($_SESSION["email"]) && in_array($_SERVER["REQUEST_URI"], $managerPages)) {  //You are logged in as a user, trying to see a manager page.
							echo "<a href = 'logout.php'> Logout </a>";
							echo "</span></div><div class='main'>";
							echo "You must be logged in as a manager to view this page.";
							require('footer.php');
							die();
						} else if (isset($_SESSION['email']) or isset($_SESSION['emp_id'])) { // You are logged in
							echo "<a href = 'logout.php'> Logout </a>";
						}
					?>
				</span>

			</div>

			<!-- PAGE CONTENT -->
			<div class='main'>
